<template>
  <!-- 合同管理 -->
  <a-card
    :width="1000"
  >
    <table class="contract-table">
      <tr>
        <th colspan="4">合同信息</th>
      </tr>
      <tr>
        <td style="width: 220px">订单号</td>
        <td style="width: 300px">{{ model.orderNumber }}</td>
        <td style="width: 220px">合同签订日期</td>
        <td>{{ model.contractSignTime | filterTime(model.contractSignTime) }}</td>
      </tr>
      <tr>
        <td>合同编号</td>
        <td style="min-width: 100px">{{ model.contractNo }}</td>
        <td>合同类型</td>
        <td>{{ model.sellingType == '1' ? '个人零售' : '批售' }}</td>
      </tr>

      <tr>
        <th colspan="4">销售方信息</th>
      </tr>
      <tr>
        <td>企业名称</td>
        <td>{{ model.enterpriseName }}</td>
        <td>社会信用统一代码</td>
        <td>{{ model.enterpriseUscc }}</td>
      </tr>
      <tr>
        <td>销售区域</td>
        <td>{{ model.region }}</td>
        <td>销售地址</td>
        <td>{{ model.businessAddress }}</td>
      </tr>
      <tr>
        <td>销售顾问姓名</td>
        <td>{{ model.salesName }}</td>
        <td>销售顾问手机号码</td>
        <td>{{ model.salesPhone }}</td>
      </tr>


      <tr>
        <th colspan="4">购买方信息(与"机动车销售统一发票"信息一致)</th>
      </tr>
      <tr>
        <td>购车方姓名</td>
        <td>{{ model.buyerName }}</td>
        <td>购买方手机号码</td>
        <td>{{ model.buyerPhone }}</td>
      </tr>
      <tr>
        <td>购买方性质</td>
        <td>{{ model.buyerType == '1'? '个人': model.buyerType == '2'? '公司':'' }}</td>
        <td colspan="2"></td>
      </tr>
      <tr>
        <td>购买方证件类型</td>
        <td v-if="model.pinType == 1">身份证</td>
        <td v-else-if="model.pinType == 2">护照</td>
        <td v-else-if="model.pinType == 3">士兵证军官证</td>
        <td v-else-if="model.pinType == 4">港澳居民居住证</td>
        <td v-else-if="model.pinType == 5">港澳居民来往内地通行证</td>
        <td v-else-if="model.pinType == 6">台湾居民居住证</td>
        <td v-else-if="model.pinType == 7">台湾居民来往大陆通行证</td>
        <td v-else-if="model.pinType == 8">外国人永久居留身份证</td>
        <td v-else-if="model.pinType == 9">其他有效身份证明</td>
        <td v-else>{{ model.pinType }}</td>
        <td>购买方证件号码</td>
        <td>{{ model.pinNumber }}</td>
      </tr>

      <tr>
        <th colspan="4">车辆信息</th>
      </tr>
      <tr>
        <td>汽车品牌</td>
        <td>{{ model.carBrand }}</td>
        <td>汽车型号</td>
        <td>{{ model.carModel }}</td>
      </tr>
      <tr>
        <td>车辆类型</td>
        <td v-if="model.carType == 1">传统车</td>
        <td v-else-if="model.carType == 2">新能源汽车</td>
        <td v-else>{{ model.carType }}</td>
        <td>车架号(vin码)</td>
        <td>{{ model.carVin }}</td>
      </tr>
      <tr>
        <td>车型配置</td>
        <td>{{ model.carTypeConfiguration }}</td>
        <td>汽车燃料类型</td>
        <td v-if="model.fuelType == 1">油/电</td>
        <td v-else-if="model.fuelType == 2">电</td>
        <td v-else-if="model.fuelType == 3">汽油</td>
        <td v-else></td>
      </tr>
      <tr>
        <td>外饰颜色</td>
        <td>{{ model.carColor }}</td>
        <td>内饰颜色</td>
        <td>{{ model.interiorColor }}</td>
      </tr>
      <tr>
        <td>发动机号</td>
        <td>{{ model.engineNumber }}</td>
        <td>动力蓄电池组编号</td>
        <td>{{ model.batteryNumber }}</td>
      </tr>
      <tr>
        <td>电池发票号</td>
        <td>{{ model.batteryInvoiceNumber }}</td>
        <td>电池发票时间</td>
        <td>{{ model.batteryInvoiceTime }}</td>
      </tr>
      <tr>
        <td>合格证号</td>
        <td>{{ model.qualifiedNumber }}</td>
        <td>货物进口证明书编号</td>
        <td>{{ model.importProveNumber }}</td>
      </tr>
      <tr>
        <td>进口机动车辆随车检验单号</td>
        <td>{{ model.importEngineNumber }}</td>
        <td>充电条件落实方式</td>
        <td>{{ model.chargeCondition | filterChargeType(model.chargeCondition) }}</td>
      </tr>

      <tr>
        <th colspan="4">支付信息</th>
      </tr>
      <tr>
        <td>总价</td>
        <td>{{ model.finalPrice | filterNumber(model.finalPrice) }}</td>
        <td>付款类型</td>
        <td>{{ model.paytype == '1'? '按揭' : model.paytype == '2'? '一次性付款':'' }}</td>
      </tr>
      <tr v-for="item in model.paymentMethodJson">
        <td colspan="4">
          <a-row type="flex" justify="start">
            <a-col :span="8">支付方式: {{ item.paymentMethod | filterPaymentMethod(item.paymentMethod)}}</a-col>
            <a-col :span="8">金额: {{ item.paymentAmount | filterNumber(item.paymentAmount)}}</a-col>
            <a-col :span="8">付款时间: {{ item.paymentDate | filterPaymentDate(item.paymentDate)}}</a-col>
          </a-row>
        </td>
      </tr>

      <tr>
        <th colspan="4">交易信息("机动车销售统一发票"信息)</th>
      </tr>
      <tr>
        <td>开票日期</td>
        <td>{{ model.invoiceTime | filterTime(model.invoiceTime) }}</td>
        <td>发票代码</td>
        <td>{{ model.invoiceCode }}</td>
      </tr>
      <tr>
        <td>发票号码</td>
        <td>{{ model.invoiceNumber }}</td>
        <td>不含税价</td>
        <td>{{ model.excludingTaxPrice | filterNumber(model.excludingTaxPrice) }}</td>
      </tr>
      <tr>
        <td>价税合计</td>
        <td>{{ model.invoicePrice | filterNumber(model.invoicePrice) }}</td>
        <td>总实收</td>
        <td>{{ model.receivedamount }}</td>
      </tr>

      <tr>
        <th colspan="4">预交付信息</th>
      </tr>
      <tr>
        <td>交付方式</td>
        <td>{{ model.deliveryMethod == '1' ? '自提' : model.deliveryMethod == '2'? '委托':'' }}</td>
        <td>预定交车地点</td>
        <td>{{ model.deliveryAddr }}</td>
      </tr>
      <tr>
        <td>预定交车时间</td>
        <td>{{ model.deliveryTime }}</td>
        <td colspan="2"></td>
      </tr>
      <template v-if="model.agentOrNot == '是'">
        <tr>
          <th colspan="4">代办服务</th>
        </tr>
        <tr>
          <td colspan="4">{{ model.agentContents }}</td>
        </tr>
      </template>
      <template v-if="model.agentOrNot == '1'">
        <tr>
          <th colspan="4">代办服务</th>
        </tr>
        <tr v-for="item in model.agentContentsJson">
          <td>代办项目内容</td>
          <td>{{ item.agentContents }}</td>
          <td>备注</td>
          <td>{{ item.remarks }}</td>
        </tr>
        <tr v-if="!model.agentContentsJson">
          <td colspan="4">暂无代办服务</td>
        </tr>
      </template>

    </table>
  </a-card>
</template>

<script>
import moment from 'moment'

export default {
  name: 'contractInfo',
  props:{
    model:{
      type:Object,
      default:()=>{}
    }
  },
  data() {
    return {
      confirmLoading: false,
      url: {
        add: '/cxm/cxmContractManager/add',
        edit: '/cxm/cxmContractManager/edit'
      }
    }
  },
  filters: {
    filterTime(time) {
      return time? moment(time).format('YYYY-MM-DD') :''
    },
    filterPaymentMethod(paymentMethod) {
      switch (paymentMethod) {
        case '1':
          return '刷卡'
        case '2':
          return '转账'
        case '3':
          return '支票'
        case '4':
          return '现金'
        case '5':
          return '微信'
        case '6':
          return '支付宝'
        case '7':
          return '银行承兑汇票'
        case '8':
          return '预付'
        case '9':
          return '本票'
        case '10':
          return '会员电子账户'
        case '11':
          return '门店储值卡'
        case '13':
          return '券支付'
        case '14':
          return '电汇'
        case '15':
          return '挂账'
        case '16':
          return '公户'
        default:
          return paymentMethod
      }
    },
    filterPaymentDate(paymentDate) {
      return paymentDate? new Date(new Date(paymentDate).getTime()).toLocaleString():''
    },
    filterNumber(value) {
      return value? Number(value).toFixed(2) + '元':''
    },
    filterChargeType(value) {
      switch (value) {
        case '1':
          return '自建'
          break;
        case '2':
          return '专用'
          break;
        case '3':
          return '公用'
      }
    }
  }
}
</script>

<style lang="less" scoped>
.contract-table {
  width: 1100px;
  margin: 10px auto;
}
.contract-table tr th {
  height: 30px;
  border: 1px solid #000;
  background-color: #e6e6e6;
  padding-left: 5px;
}
.contract-table tr td {
  height: 30px;
  border: 1px solid #000;
  min-width: 80px;
  text-align: center;
}
</style>
